# -*- coding: utf-8 -*-
# @description: wsgi客户端
# @File  : app.py
# @Time  :2020-03-16 14:09:54
# @Author:selfeasy
# @Email :gm_selfeasy@163.com

# class application():

#     def __init__(self):
#         pass

#     def __call__(self, environ, start_response):
#         status = "200 OK"
#         headrs = [('Content-Type', 'application/json')]
#         start_response(status, headrs)
#         print(environ)
#         return str(environ['wsgi.input'])
# application = application()

class application():
    def __init__(self,environ, start_response):
        self.environ = environ
        self.start_response = start_response
    
    def __iter__(self):
        status = "200 OK"
        headrs = [('Content-Type', 'application/json')]
        self.start_response(status, headrs)
        print(self.environ)
        yield str(self.environ['wsgi.input'])

'''wsgi客户端可以是一个函数

def application(environ, start_response):
    status = "200 OK"
    headrs = [('Content-Type', 'application/json')]
    start_response(status, headrs)
    print(environ)
    return str(environ['wsgi.input'])

'''